class RightsRoles < ActiveRecord::Migration
  def self.up
    create_table :rights_roles,:id => false do |t|
      t.column "right_id", :integer
      t.column "role_id", :integer
    end
    right1 = Right.create(:name=>"编辑账号角色",:description=>"编辑账号角色")
    right2 = Right.create(:name=>"编辑资料",:description=>"编辑资料")
    right3 = Right.create(:name=>"管理订单",:description=>"管理订单")
    admin = Role.find_by_name('超级管理员')
    admin.rights << [right1,right2,right3]

    editor = Role.find_by_name('网站编辑')
    editor.rights << right2

    order_admin = Role.find_by_name('跟单员')
    order_admin.rights << right3
  end

  def self.down
    drop_table :rights_roles
  end
end
